<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
		<meta charset="utf-8" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">学校用户信息</a></li>
    <li><a href="#">系统管理员</a></li>
   
    </ul>
    </div>
    
    <div class="rightinfo">
    
    <div class="tools">
    <form id="searchForm" class="form-search"
						action="admin/admin_page_list.do" method="post">
    	<ul class="seachform1">
    		<li>选择院系：</li>  
    	    <li>
    	    <select name="deptName" class="chosen-select col-xs-10 col-sm-5" >
						<option value="" > -- 全部 -- </option>
						<c:forEach items="${departmentInfoList}" var="departmentInfo">
							<option value="${departmentInfo.XYMC }" <c:if test="${departmentInfo.XYMC == deptName }">selected</c:if> >${departmentInfo.XYMC }</option>
						</c:forEach>
					</select>
    	</li>
		<li><input name="teacherName" type="text" class="scinput1" value="${teacherName }" placeholder="输入管理员" /></li>
		<li><input name="" type="button" id="btnSearch" class="scbtn" value="查询"/></li>  
		<div class="clearfix"></div>
		</ul>	
		 <input type="hidden" name="pageNumber" value="1" />
    	</form>
    	<!--<ul class="toolbar">
        <li class="click"><span><img src="images/t01.png" /></span>添加</li>
        <li class="click"><span><img src="images/t02.png" /></span>修改</li>
        <li><span><img src="images/t03.png" /></span>删除</li>
        <li><span><img src="images/t04.png" /></span>统计</li>
        </ul>
        
        
        <ul class="toolbar1">
        <li><span><img src="images/t05.png" /></span>设置</li>
        </ul>
    -->
    </div>
    <table class="tablelist">
    	<thead>
    	<tr>
        <th>教师工号</th>
        <th>教师姓名</th>
		<th>所属院系</th>
        <th>角色</th>
        <th>操作</th>
      </tr>
        </thead>
        <tbody>
          <c:forEach items="${adminList}" var="admin"  varStatus="status">
          <tr>
      	 <td>${admin.teacherNumber }</td>
        <td>${admin.teacherName }</td>
        <td>${admin.deptName }</td>
        <td>${admin.roleName}</td>
		<td><c:if test="${admin.teacherNumber != admin_account}"><a onclick="adminDelete('${admin.teacherNumber }');">删除</a>&nbsp;&nbsp;&nbsp;&nbsp;</c:if>
		<c:if test="${admin.userRole==3}">
		<a onclick="schoolAdministrators('${admin.teacherNumber }');">指定学校管理员</a></c:if></td>
      </tr> 
          </c:forEach>
        </tbody>
    </table>
    <div class="pagin">
    	<%@ include file="page.jsp"%>
    </div>
    </div>
    <script src="js/jquery-1.7.2.js"></script>
     <script src="layer/layer.js"></script>
    <script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	$( "#btnSearch" ).on('click', function(e) {
		$("#searchForm").submit();
	});
	function GoToPage(toPage,totalPage) {
	    if(toPage<=0) return;
	    if(toPage>totalPage) return;
	    $("input[name='pageNumber']").val(toPage);
	    $("#searchForm").submit();
	};
	function adminDelete(teacherNumber) {
		$.ajax({
			type: "GET",
			url: "admin/delete.do?teacherNumber="+teacherNumber,
			async: true,
			dataType: "json",
			success: function(data) {
				if("success" == data.result){
					layer.alert('删除成功!', {
			            skin: 'layer-ext-moon' 
					}, function(){
					 location.reload();
					 });
					}else {
						layer.alert('删除失败!', {
				            skin: 'layer-ext-moon' 
				        });
						}
				}
			})
	};
	function schoolAdministrators(teacherNumber) {
		$.ajax({
			type: "GET",
			url: "admin/schoolAdministrators.do?teacherNumber="+teacherNumber,
			async: true,
			dataType: "json",
			success: function(data) {
				if("success" == data.result){
					layer.alert('指定成功!', {
			            skin: 'layer-ext-moon' 
					}, function(){
					 location.reload();
					 });
					}else {
						layer.alert('指定失败!', {
				            skin: 'layer-ext-moon' 
				        });
					}
				}
			})
	};
	</script>
</body>

</html>
